package com.symria.server.dao.common;

import java.util.Date;

import com.symria.framework.dao.util.TemplateDao;
import com.symria.framework.page.Page;
import com.symria.server.po.AppDateReport;
import com.symria.server.po.UserInfo;
import com.symria.system.statement.Statement;

public class FinanceDao extends TemplateDao {

    public void searchAppDateReport(AppDateReport aar,Date beginDate,Date endDate,Page page){
		Statement stms = stmsFactory.createStatement(" from AppDateReport aar where 1=1 ");
		          if(aar!=null){
		        	  stms.append("and", "aar.state", "=", aar.getState());
		          }
		          stms.appendBetween("and", "aar.createTime", beginDate, endDate);
		          stms.addOrderBy(" aar.createTime desc ");
	  templateDao.search(stms, page);
	}
    
    public void searchUserAccount(UserInfo user,Date beginDate,Date endDate,Page page){
    	Statement stms = stmsFactory.createStatement(" select u,a from UserInfo u,UserAccount a where u.userId=a.userId");
    	          if(user!=null){
    	        	  stms.appendLike(null, "and", "u.userName", user.getUserName());
    	          } 
    	          stms.appendBetween("and", "u.createDate", beginDate, endDate);
    	          
    	          stms.addOrderBy("a.payMoney desc u.userId desc");
    	templateDao.search(stms, page);
    }
    
    public void searchPayInfo(UserInfo user,Date beginDate,Date endDate,String state,Page page){
        Statement stms = stmsFactory.createStatement(" select u,p from UserInfo u,PayInfo p where u.userId=p.userId");
                  stms.appendBetween("and", "p.createDate", beginDate, endDate);
                  stms.append("and", "p.state", "=", state);
                  stms.addOrderBy("p.createDate desc ");
        templateDao.search(stms, page);
    }
}
